import 'package:canteen/page/staff_detail_page.dart';
import 'package:canteen/userDetail.dart';
import 'package:flutter/material.dart';

class ManageStaffPage extends StatefulWidget {
  static String id = 'manage_staff_page';

  const ManageStaffPage({super.key});

  @override
  State<ManageStaffPage> createState() => _ManageStaffPageState();
}

class _ManageStaffPageState extends State<ManageStaffPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xfffbfbfb),
      appBar: AppBar(
        backgroundColor: Color(0xffffffff).withOpacity(0.89),
        elevation: 0,
        centerTitle: true,
        title: Text(
          '管理员工',
          style: TextStyle(color: Colors.black, fontSize: 16),
        ),
        leading: GestureDetector(
          onTap: () {
            Navigator.pop(context);
          },
          child: Icon(
            Icons.arrow_back_rounded,
            color: Colors.black,
          ),
        ),
      ),
      body: Container(
        margin: EdgeInsets.symmetric(horizontal: 10, vertical: 15),
        child: Column(
          children: [
            Expanded(
              child: GridView.builder(
                itemCount: allStaffs.length,
                itemBuilder: (context, index) {
                  return GestureDetector(
                    onTap: () {
                      Navigator.pushNamed(context, StaffDetailPage.id,
                          arguments: {
                            'username': allStaffs[index].username,
                            'staffType': allStaffs[index].type,
                            'password': allStaffs[index].password,
                            'id': allStaffs[index].id,
                          }).then((value) {
                        setState(() {});
                      });
                    },
                    child: Stack(
                      children: [
                        Container(
                          alignment: Alignment.center,
                          padding:
                              EdgeInsets.symmetric(horizontal: 10, vertical: 8),
                          decoration: BoxDecoration(
                              boxShadow: [
                                BoxShadow(
                                    offset: Offset(0, 1),
                                    blurRadius: 2,
                                    color: Colors.black.withOpacity(0.25))
                              ],
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(15)),
                          child: Text(
                            allStaffs[index].username,
                            style: TextStyle(fontSize: 16),
                          ),
                        ),
                        Positioned(
                          left: 8,
                          top: 8,
                          child: Container(
                            height: 12,
                            width: 12,
                            decoration: BoxDecoration(
                              shape: BoxShape.circle,
                              border: Border.all(
                                  color: Colors.black.withOpacity(0.6),
                                  width: 0.5),
                            ),
                          ),
                        ),
                      ],
                    ),
                  );
                  //   DishWidget(
                  //   dishName: setMeal.dishes.keys
                  //       .map((e) => e.name)
                  //       .toList()[index],
                  //   childWidget: Text(
                  //       '×${setMeal.dishes.values.toList()[index]}'),
                  // );
                },
                gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                  childAspectRatio: 2,
                  crossAxisSpacing: 10,
                  mainAxisSpacing: 10,
                  crossAxisCount: 2,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
